package cn.tj212.xiaoyin.dto;

public class ResponseObj<T>{
    private int code;
    private String msg;
    private T data;




    private ResponseObj(T data) {
        this.code=0;
        this.msg="success";
        this.data = data;
    }

    public static <T> ResponseObj<T> success(T data){
        return new ResponseObj<T>(data);
    }

    private ResponseObj(CodeMsg msg) {
        if (msg==null){
            return;
        }
        this.code=msg.getCode();
        this.msg = msg.getMsg();
    }

    public static <T> ResponseObj<T> error(CodeMsg msg){
        return new ResponseObj<T>(msg);
    }

    public int getCode() {
        return code;
    }


    public String getMsg() {
        return msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
